package com.uh.summary.controller;

import com.uh.summary.enums.RuleTypeEnum;
import com.uh.summary.service.IWarnEnterpriseRecordService;
import org.apache.commons.lang3.EnumUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
public class WarnEnterpriseRecordController {

    @Resource
    IWarnEnterpriseRecordService iWarnEnterpriseRecordService;

    @GetMapping("/call_compute/no_edit/{type}")
    public int callNoEditCompute(@PathVariable("type") String typeEnum) {
        return iWarnEnterpriseRecordService.saveNoEditRecords(EnumUtils.getEnum(RuleTypeEnum.class, typeEnum));
    }


    @GetMapping("/call_batch/no_edit")
    public int callNoEditBatch(@RequestParam String typeEnum,@RequestParam String lastTime) {
        return iWarnEnterpriseRecordService.saveNoEditBatch(EnumUtils.getEnum(RuleTypeEnum.class, typeEnum),lastTime);
    }

    @GetMapping("call_compute/edit/{type}/{years}")
    public int callEditCompute(@PathVariable("type") String type, @PathVariable("years") String years) {
        return iWarnEnterpriseRecordService.saveEditRecords(EnumUtils.getEnum(RuleTypeEnum.class, type), years);
    }


}
